/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SessionBeans;

import Entidades.Supply;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Pedro
 */
@Stateless
public class SupplyFacade extends AbstractFacade<Supply> {

    @PersistenceContext(unitName = "WebApplicationPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public SupplyFacade() {
        super(Supply.class);
    }

    public Supply findSupplyByID(Integer id) {
        Query q = null;
        q = (Query) em.createQuery("select s FROM Supply s where s.ID = :ID");
        q.setParameter("ID", id);
        System.out.println(q.getFirstResult());
        return (Supply) q.getSingleResult();

    }
}
